package Class;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: homechen
 * Date: 2024-03-17
 * Time: 21:53
 */

import java.util.Comparator;
import java.util.HashMap;
import java.util.PriorityQueue;

/**
 * 定义抽象类
 */
public class Shape {
    public static void main(String[] args) {
        HashMap<Character, Integer> hashMap = new HashMap<>();
        hashMap.put('c', 0);
        hashMap.put('r', 1);
        hashMap.put('o', 2);
        hashMap.put('a', 3);
        hashMap.put('d', 4);
        String str = new String();
    }

    public static void main2(String[] args) {
        PriorityQueue<Integer> queue = new PriorityQueue<>(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o2 - o1;
            }
        });
    }

    public static void main1(String[] args) {
        char[] name = {'唐', '晨'};
        System.out.println("之前：" + new String(name));
        //func1(name); // 这里修改的是副本
        func2(name); //
        System.out.println("之后：" + new String(name));
        Throwable throwable = new Throwable();

        StringBuilder str = new StringBuilder("1");
        System.out.println(str.toString());
    }

    private static void func2(char[] name) {
        name = new char[2];
        name[1] = '成';
        System.out.println("方法2：" + new String(name));
    }

    private static void func1(char[] name) {
        name[1] = '乘';
        System.out.println("方法1：" + new String(name));
    }

    //    StringBuilder
//    StringBuffer stringBuffer = new StringBuffer();
//    public static void main(String[] args) {
////        String s = new String("hello");
////        s.intern(); // 尝试放入字符串常量池
//        int num = 10;
//        func(num);
//        System.out.println(num);
//    }
//
//    private static void func(int num) {
//        num = 20;
//    }
}
